package com.lyb.mapper;

import com.lyb.Dto.BookDto;
import com.lyb.pojo.Book;
import com.lyb.pojo.BookCategory;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {
    @Insert("insert into book (name,createTime,updateTime) values (#{book.name},#{book.createTime},#{book.updateTime})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void addBook(@Param("book") BookDto book);
//    @Select("select * from book")
    List<Book> queryBookPage();
    @Delete("delete from book where id=#{id}")
    Boolean del(Integer id);
    @Update("update book set name=#{book.name},updateTime=#{book.updateTime} where id=#{book.id}")
    Boolean update(@Param("book") Book book);
    @Select("select * from book_category where bookId=#{id}")
    BookCategory findByBookId(Long id);
}
